import 'package:base_flutter/base_flutter.dart';

class Apis {

  ///正式服
  // static String base_url = "https://zhyly.joyhave.com/ophApi/";

  ///测试服
  static String base_url = "https://zhylytest.yytong.com/ophApi/";

  ///登录
  static String get login => "${base_url}auth/login";

  ///扫码提交
  static String get scan => "${base_url}welfareVisitorRegistration/vistor";

  ///检测登录
  static String get checkLogin => "${base_url}org/getValidBranchByCurrUser";

  ///获取百度token
  static String get getBaiduToken => "${base_url}welfareVisitorRegistration/baiduAiToken";

  ///百度车牌识别
  static String get baiduCar => "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate";
}

class PostRequest{

  static Future<Map> login (String username,String password) async {
    var map = {
      "username":username,
      "password":password
    };

    var result = await  HttpGo.instance.postData(Apis.login,data: map,options: Options());
    return result;
  }

  static Future<Map> updateScan(String code,String carNo) async {
    var map = {
      "code":code,
      "carNo":carNo
    };
    var result = await HttpGo.instance.postData(Apis.scan,data: map,options: Options(contentType: Headers.formUrlEncodedContentType));
    return result;
  }

  static Future<Map> checkLogin() async {
    var result = await HttpGo.instance.getData(Apis.checkLogin);
    return result;
  }

  static Future<Map> getBaiduCar(String token,String image) async {
    var map = {
      "image":image
    };
    var url = "${Apis.baiduCar}?access_token=$token";
    var result = await HttpGo.instance.postData(url,data: map,options: Options());
    return result;
  }

  ///获取token
  static Future<Map> getBaiduToken() async {
    var result = await HttpGo.instance.getData(Apis.getBaiduToken);
    return result;
  }
}